import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;

public class TestRockPapersScissors {
	RockPaperScissors rps;
	Player player;

	@BeforeClass
	public void setUpClass() {
		rps = new RockPaperScissors();
		player = new Player(null, null);
	}

	@AfterClass
	public void tearDownClass() {
		rps = null;
		player = null;
	}

	@DataProvider(name = "WIN")
	public Object[][] createWinData() {

		return new Object[][] { { RPSEnum.ROCK, RPSEnum.SCISSORS },
				{ RPSEnum.SCISSORS, RPSEnum.PAPER },
				{ RPSEnum.PAPER, RPSEnum.ROCK }, };

	}

	@DataProvider(name = "TIE")
	public Object[][] createTieData() {

		return new Object[][] { { RPSEnum.ROCK, RPSEnum.ROCK },
				{ RPSEnum.SCISSORS, RPSEnum.SCISSORS },
				{ RPSEnum.PAPER, RPSEnum.PAPER }, };

	}

	@DataProvider(name = "LOST")
	public Object[][] createLostData() {

		return new Object[][] { { RPSEnum.ROCK, RPSEnum.PAPER },
				{ RPSEnum.SCISSORS, RPSEnum.ROCK },
				{ RPSEnum.PAPER, RPSEnum.SCISSORS }, };

	}

	@Test(dataProvider = "WIN")
	public void testWinPlay(RPSEnum p1, RPSEnum p2) {
		RockPaperScissors winplay = new RockPaperScissors();
		Result result = winplay.play(p1, p2);
		Assert.assertEquals(result, Result.WIN);

	}

	@Test(dataProvider = "TIE")
	public void testTiePlay(RPSEnum p1, RPSEnum p2) {
		RockPaperScissors tieplay = new RockPaperScissors();
		Result result = tieplay.play(p1, p2);
		Assert.assertEquals(result, Result.TIE);
	}

	@Test(dataProvider = "LOST")
	public void testLostPlay(RPSEnum p1, RPSEnum p2) {
		RockPaperScissors lostplay = new RockPaperScissors();
		Result result = lostplay.play(p1, p2);
		Assert.assertEquals(result, Result.LOST);
	}

}
